
<div class="container ui-sortable" style="clear:both;">
    <p></p>
    <div class="col-xs-12 col-sm-3">
        {include file="index@layouts/leftmenu" /}
    </div>
    <div class="col-xs-12 col-sm-9" style="padding-left:2px;">
        <div class="panel panel-default ">
            <div class="panel-header">[tblTitle]</div>
            <div class="panel-body">
                <form action="" method="post" class="form form-horizontal responsive" id="demoform">
[loop start]
		    <div class="row cl">
                        <label class="form-label col-xs-3">[fldTitle]：</label>
                        <div class="formControls col-xs-8">
                            <input type="text" class="input-text" placeholder="[fldTitle]" name="[fldName]" id="txt{fldName}" autocomplete="off">
                        </div>
                    </div>
                          [loop end]
 
                    <div class="row cl">
                        <div class="col-xs-8 col-xs-offset-3"><input type="hidden" name="id" id="txtId"  value="0">
                            <button id="btnSubmit" onclick="javascript:formAddSubmit();return false;" class="btn btn-primary">提交</button>
                            
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>


</div>

<script>

$(function(){
    initPage();
    loadData();
});

//初始化页面元素
function initPage() {

}

//加载数据
function loadData() {
    var id=GetQueryString("id");
    var url = ApiHost + "/{tblName}View";
    $.ajax({
            type: "post",
            url: url,
            data: {
                id:id
            },
            dataType: "json",
            error: function (request) {
                ajaxError(request, $(this));
            },
            success: function (result) {
                ajaxSuccess(result, $(this));
                var code=result.statecode;
                if(code==0){
                    loadJson(result.data);
                }else{
                    layerAlert("获取失败："+result.message);
                }
            }
        }
    );

}

//保存数据
function formAddSubmit() {
    var url = ApiHost + "/{tblName}Add";
    var formData =$('#formadd').serialize();
    $.ajax({
            type: "post",
            url: url,
            data: formData,
            dataType: "json",
            error: function (request) {
                ajaxError(request, $(this));
            },
            success: function (result) {
                ajaxSuccess(result, $(this));
                var code=result.statecode;
                if(code==0){
                    //layerAlert("提交成功");
                    layerAlert("成功",function () {
                        parent.layerCallBack();
                        closeLayer();
                    })
                }else{
                    layerAlert("提交失败："+result.message);
                }
            }
        }
    );

}

</script>




